﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using IDAL;

namespace DAL
{
    /// <summary>
    /// 攻略
    /// </summary>
    public class D_Strateg : IStrateg
    {
        WishDayEntities _es;
        public D_Strateg()
        {
            _es = new WishDayEntities();
        }
        public void Add(Strateg obj)
        {
            _es.Strateg.Add(obj);
            _es.SaveChanges();
        }

        public void Delete(int id)
        {
            _es.Strateg.Remove(_es.Strateg.Find(id));
            _es.SaveChanges();
        }

        public Strateg FindById(int id)
        {
            return _es.Strateg.Find(id);
        }

        public List<Strateg> GetAll()
        {
            return _es.Strateg.ToList();
        }

        public void Update(int id, Strateg obj)
        {
            var data = _es.Strateg.Find(id);
            data.StrategName = obj.StrategName;
            data.Paragraph = obj.Paragraph;
            data.Describe = obj.Describe;
            data.SImage = obj.SImage;
            data.Show = obj.Show;
            data.Thumbsup = obj.Thumbsup;
            data.CreateTime = obj.CreateTime;
            data.STypeID = obj.STypeID;
            _es.SaveChanges();
        }
    }
}
